<template>
	<view class="integral">
		<view class="navbar">
			<dwu-integral-navbar title="我的积分" bgColor="transparent"></dwu-integral-navbar>
		</view>
		<view class="integral-box">
			<image class="number-bg" src="@/static/integral/number_bg.png" mode=""></image>
			<view class="number">
				<text>{{dwuUserinfo.score}}</text>
				<!-- <text>1.00</text> -->
				<text>积分余额</text>
			</view>
			<view class="recharge" @click="onJump('/subpackage/integral/recharge')">
				<image class="btn-bg" src="@/static/integral/btn_bg.png" mode=""></image>
				<image class="recharge-icon" src="@/static/integral/recharge_icon.png" mode=""></image>
				<text>去充值</text>
			</view>
		</view>
		<view class="integral-title" @click="onJump('/subpackage/integral/info')">
			<view class="left">变动明细</view>
			<view class="right">
				<text>全部</text>
				<image src="@/static/news/arrow_right.png" mode=""></image>
			</view>
		</view>
		<!-- <scroll-view class="integral-list" scroll-y :style="'height:calc(100vh - '+ offsetTop +')'" @scrolltolower="scrolltolower">
			<view class="integral-item" v-for="(item,index) in integralList" :key="index">
				<image class="item-bg" src="@/static/integral/item_bg.png" mode=""></image>
				<view class="left">
					<view class="label">
						{{item.memo}}
					</view>
					<view class="time">
						{{item.createtime | formattingTime}}
					</view>
				</view>
				<view class="right">
					<text>{{item.score}}</text>
				</view>
			</view>
		</scroll-view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				offsetTop: 0,
				integralList: [],
				page: 1,
				pageSize: 10,
				flag: false,
				dwuUserinfo: {}
			};
		},
		onShow() {
			this.getHeight()
		},
		onLoad() {
			let dwuUserinfo = uni.getStorageSync('dwu_userinfo')
			this.dwuUserinfo = dwuUserinfo
			this.getIntegralList()
		},
		methods: {
			getHeight() {
				const query = uni.createSelectorQuery().in(this);
				query.select('.navbar').boundingClientRect(data => {
					if (data) {
						this.offsetTop = ((data.height * 2) + 380) + 'rpx'
						this.$forceUpdate()
					}
				}).exec();
			},
			scrolltolower() {
				if (this.flag) return
				this.page++
				this.flag = true
				this.getIntegralList(true)
			},
			getIntegralList(next) {
				this.request.http('/Moneyorder/index', 'post', {
					page: this.page,
					limit: this.pageSize,
				}).then(res => {
					let data = res.data
					if (data.code == 1) {
						if (next) {
							if (data.data.data.length > 0) {
								this.integralList = this.integralList.concat(data.data.data)
								this.flag = false
							}
						} else {
							this.integralList = data.data.data
							this.flag = false
						}
					}
				})
			},
			onJump(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background: #F7F9F9;
	}

	.integral {
		.navbar {
			position: relative;

			.nav-bg {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				z-index: -1;
			}
		}

		.integral-box {
			margin-top: 22rpx;
			position: relative;
			height: 282rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.number-bg {
				position: absolute;
				z-index: 1;
				width: 100%;
				height: 100%;
				top: 0;
				left: 0;
			}

			.number {
				margin-left: 100rpx;
				position: relative;
				z-index: 10;
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;

				text {
					&:first-child {
						font-family: DINAlternate, DINAlternate;
						font-weight: bold;
						font-size: 87rpx;
						color: #313131;
						line-height: 100rpx;
					}

					&:last-child {
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 31rpx;
						color: #313131;
						line-height: 42rpx;
					}
				}
			}

			.recharge {
				margin-right: 21rpx;
				position: relative;
				z-index: 10;
				width: 290rpx;
				height: 82rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				.btn-bg {
					position: absolute;
					z-index: 1;
					top: 0;
					left: 0;
					width: 100%;
					height: 100%;
				}

				.recharge-icon {
					margin-right: 14rpx;
					position: relative;
					z-index: 10;
					width: 30rpx;
					height: 30rpx;
				}

				text {
					position: relative;
					z-index: 10;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 27rpx;
					color: #B0DD67;
					line-height: 38rpx;
				}
			}
		}

		.integral-title {
			background-color: #fff;
			box-shadow: 0rpx 4rpx 13rpx 8rpx rgba(245,245,245,0.16);
			border-radius: 34rpx;
			padding: 32rpx 50rpx;
			width: 720rpx;
			margin: 34rpx auto 0;
			// padding: 22rpx 44rpx 4rpx 34rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.left {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 27rpx;
				color: #474747;
			}

			.right {
				display: flex;
				align-items: center;

				text {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 27rpx;
					color: #999999;
				}

				image {
					margin-left: 12rpx;
					width: 10rpx;
					height: 20rpx;
				}
			}
		}

		.integral-list {
			// height: calc(100vh - 282rpx - 66rpx - 130rpx);

			.integral-item {
				position: relative;
				width: 100%;
				height: 196rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.item-bg {
					position: absolute;
					z-index: 1;
					width: 100%;
					height: 100%;
					top: 0;
					left: 0;
				}

				.left {
					padding-left: 60rpx;
					position: relative;
					z-index: 10;
					display: flex;
					justify-content: center;
					flex-direction: column;

					.label {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 27rpx;
						color: #474747;
						line-height: 38rpx;
					}

					.time {
						margin-top: 12rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 23rpx;
						color: #868686;
						line-height: 33rpx;
					}
				}

				.right {
					padding-right: 72rpx;
					position: relative;
					z-index: 10;

					text {
						&:first-child {
							font-family: DINCondensed, DINCondensed;
							font-weight: bold;
							font-size: 46rpx;
							color: #474747;
						}

						&:last-child {
							font-family: DINCondensed, DINCondensed;
							font-weight: bold;
							font-size: 50rpx;
							color: #474747;
						}
					}
				}
			}
		}
	}
</style>